package com.hbpu.encap.IO;

import java.io.*;

public class Homework01 {
    public static void main(String[] args) throws IOException {
        String path = "E:\\mytemp";
        File file = new File(path);
        if (file.mkdir()) {
            System.out.println("创建成功！");
        } else {
            System.out.println("创建失败！");
        }
        try {
            if (new File(path, "hello.txt").createNewFile()) {
                System.out.println("文件创建成功！");
            } else {
                System.out.println("文件已存在！");
            }
        } catch (IOException e) {
            System.out.println("文件创建失败！");
        }

        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(path + "/hello.txt", true));
        bufferedWriter.write("hello, world~");
        bufferedWriter.newLine();
        bufferedWriter.close();
        System.out.println("写入成功！");
    }
}
